import selfNaxios from './ajaxConfig.js';
import { vendorsDanger as danger } from './config';

export function getPrintCodeByType(param) {
    /***
        {
            'isAjax': 1,
            ieStamp: new Date().getTime(),
            tenantId: tenantId,
            billType: param.billType,
            pkProcess: record.pk_process,
        }
    ***/
    Object.assign(param, {
        'isAjax': 1,
        ieStamp: new Date().getTime(),
    });
    axios({
        method: 'get',
        url: '/bo/getPrintCodeByType',
        params: param,
        headers: {
            'Cache-Control': 'no-cache'
        }
    }).then(function (response) {
        if (response.data.resultCode != 'busi_ex') {
            let data = response.data.result;
            let url = `./print/preview?serverUrl=/billView/queryBillDetail&printcode=${data}&tenantId=${param.tenantId}&sendType=2&params={"pkBill":"${param.pkBill}", "billType":"${param.billType}"}`;
            let win = window.open(encodeURI(url));
            win.location.reload();
            return;
        } else {
            danger({ 'text': response.data.exMsg });
        }
    });
}